package com.neusoft.mapper;

import java.util.List;

import com.neusoft.po.Point;
import org.apache.ibatis.annotations.*;

@Mapper
public interface PointMapper {

    @Insert("insert into point(points,userId,purchaseDate) values(#{points},#{userId},#{purchaseDate})")
    public int savePoints(Point point);

    // 得到用户所有有效积分信息
    @Select("select * from point where userId=#{userId} order by purchaseDate asc")
    public List<Point> getPoints(String userId);

    // 过期删除得到的积分
    @Delete("delete from point where pointsId=#{pointsId}")
    public int deletePoints(Point point);

    @Update("update point set points=#{points} where pointsId=#{pointsId}")
    public int updatePoint(Point point);

    // 获取一个用户的所有积分
    @Select("select sum(point) from point where userId={userId}")
    public int getAllPoints(String userId);

    // 过期删除得到的积分
    @Delete("delete from point where userId=#{userId}")
    public int deletePointsByUserId(String userId);
}
